interface MediaPlayer {
    play(audioType: string, fileName: string): void;
}

interface AdvancedMediaPlayer {
    playVlc(fileName: string): void;
    playMp4(fileName: string): void;
}

class VlcPlayer implements AdvancedMediaPlayer {
    public playVlc(fileName: string): void {
        console.log(`Playing vlc file ${fileName}`);
    }
    public playMp4(_: string): void { }
}

class Mp4Player implements AdvancedMediaPlayer {
    public playVlc(_: string): void { }
    public playMp4(fileName: string): void {
        console.log(`Playing mp4 file ${fileName}`);
    }
}

class MediaAdapter implements MediaPlayer {
    advancedPlayer: AdvancedMediaPlayer | null;
    public constructor(audioType: string = "") {
        switch (audioType.toLowerCase()) {
            case "vlc":
                this.advancedPlayer = new VlcPlayer();
                break;
            case "mp4":
                this.advancedPlayer = new Mp4Player();
                break;
            default:
                this.advancedPlayer = null;
                break;
        }
    }
    public play(audioType: string, fileName: string) {
        switch (audioType.toLowerCase()) {
            case "vlc":
                this.advancedPlayer?.playVlc(fileName);
                break;
            case "mp4":
                this.advancedPlayer?.playMp4(fileName);
                break;
            default:
                console.log("Invalid audio type");
                break;
        }
    }
}

class AudioPlayer implements MediaPlayer {
    mediaAdapter: MediaAdapter = new MediaAdapter();
    public play(audioType: string, fileName: string) {
        switch (audioType.toLowerCase()) {
            case "mp3":
                console.log(`Playing mp3 file ${fileName}`);
                break;
            case "vlc":
            case "mp4":
                this.mediaAdapter = new MediaAdapter(audioType);
                this.mediaAdapter.play(audioType, fileName);
                break;
            default:
                console.log(`Invalid media: ${audioType} format not supported`);
        }
    }
}

function main() {
    const audioPlayer: AudioPlayer = new AudioPlayer();
    audioPlayer.play("vlc", "test.vlc");
    audioPlayer.play("mp3", "test.mp3");
    audioPlayer.play("avi", "test.avi");
    audioPlayer.play("mp4", "test.mp4");
}

main();
